import { TItemSuit } from "../../../Message/Db/Tables/TItemSuit";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class SuitConfig
    
    export  class SuitConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (SuitConfig._instance != null) 
            {
                throw new Error(" SuitConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TItemSuit();
                loc1.code = loc2.code;
                loc1.suitSet = loc2.suitSet;
                loc1.name = StringHelper.getString(loc2.name);
                loc1.num = loc2.num;
                loc1.partList = StringHelper.getString(loc2.partList);
                loc1.attr1 = StringHelper.getString(loc2.attr1);
                loc1.attr2 = StringHelper.getString(loc2.attr2);
                loc1.attr3 = StringHelper.getString(loc2.attr3);
                loc1.attr4 = StringHelper.getString(loc2.attr4);
                loc1.attr5 = StringHelper.getString(loc2.attr5);
                loc1.attr6 = StringHelper.getString(loc2.attr6);
                loc1.attr7 = StringHelper.getString(loc2.attr7);
                loc1.attr8 = StringHelper.getString(loc2.attr8);
                loc1.canLock = loc2.canLock;
                loc1.attrSkill = StringHelper.getString(loc2.attrSkill);
                loc1.suitLevel = loc2.suitLevel;
                loc1.suitModel = StringHelper.getString(loc2.suitModel);
                loc1.suitShow = StringHelper.getString(loc2.suitShow);
                this._map[loc1.code] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_item_suit.json");
            this.write(loc1);
            return;
        }

        public getInfoByCode(arg1: int): TItemSuit
        {
            return this._map[arg1];
        }

        public getInfoBySuitSet(arg1: int): Array<any>
        {
            var loc2=null;
            var loc3=null;
            var loc1=[];
            var loc4=0;
            var loc5=this._map;
            for (loc3 in loc5) 
            {
                loc2 = this._map[loc3];
                if (loc2.suitSet != arg1) 
                {
                    continue;
                }
                loc1.push(loc2);
            }
            return loc1;
        }

        public getSuitNameBySuitSet(arg1: int): string
        {
            var loc1=this.getInfoBySuitSet(arg1);
            if (loc1 && loc1.length > 0) 
            {
                return loc1[0].name;
            }
            return "";
        }

        public getSuitNameByCode(arg1: int): string
        {
            var loc1=this.getInfoByCode(arg1);
            if (loc1) 
            {
                return loc1.name;
            }
            return "";
        }

        public getSuitSetByCode(arg1: int): int
        {
            var loc1=this.getInfoByCode(arg1);
            if (loc1) 
            {
                return loc1.suitSet;
            }
            return 0;
        }

        public static get instance(): SuitConfig
        {
            if (SuitConfig._instance == null) 
            {
                SuitConfig._instance = new SuitConfig();
            }
            return SuitConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: SuitConfig;
    }
